import React, { Component } from 'react'
import { withRouter } from "react-router-dom"
import { connect } from 'react-redux'
import { getBus } from '../../redux/actionCreator'
import { Msgget_tim, Send_tim } from '../../TIM/actiontim'
import { Toast } from 'antd-mobile'
import { configConsumerProps } from 'antd/lib/config-provider'
import C2c from '../Message/C2c'
class Kefu extends Component {
    constructor(props) {
        super(props)
        let businessid = this.props.location.search.split('=')
        let arr = getBus(this.props)
        arr = arr.filter((item) => {
            return item.business_id == businessid[1]
        })
        this.state = {
            business: arr[0],
            phone: arr[0]?.business_phone
        }
        localStorage.getItem('sdkready')
            ? this.props.dispatch(Msgget_tim(arr[0]?.business_phone))
            : setTimeout(() => {
                this.props.dispatch(Msgget_tim(arr[0]?.business_phone))
                console.log('超时风险')
            }, 3000, Toast.loading('Loading...', 3))
    }

    render() {
        // console.log(this.state)
        const {business} = this.state
        return (
            <div className='kefu'>
                <C2c business={business}/>
                 {/* <input
                        className='c2c-getmsg'
                        type='text'
                        // value={info}
                        // style={input}
                        // onChange={this.onChangmessage}
                    ></input> */}
            </div>
        )
    }
}
const mapStateToProps = (state) => ({
    login: state.login,
    // shop: state.shop,
    business: state.business,
    // shop_temp: state.shop_temp,
    conversation: state.conversation,
    message: state.message
})
export default withRouter(connect(mapStateToProps)(Kefu))